using CfgTable;
using Cysharp.Threading.Tasks;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_MallMonthCardPanel : UIBaseNode
    {
        #region Template Generate,don't modify
        protected class UIB_UIN_MallMonthCardPanel
        {
            #region ObjectBinding Generate
            public UnityEngine.RectTransform viewContainer { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<UnityEngine.RectTransform>("viewContainer", out var __tbv0);
                this.viewContainer = __tbv0;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify



        #region fields
        UIN_MonthCardTemplate monthCardTemplate = null;

        CfgMallType cfgMallType = null;
        #endregion fields

        #region properties

        protected UIB_UIN_MallMonthCardPanel ui { get; set; }
        protected UIMsgDispatcher uiMsgDispatcher => this._msgDispatcher as UIMsgDispatcher;

        #endregion properties

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_MallMonthCardPanel();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {
        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        /// <summary>
        /// 添加UGUI侦听
        /// </summary>
        protected override void AddUGUIListener()
        {

        }

        /// <summary>
        /// 添加全局侦听（MsgDispatcher）
        /// </summary>
        protected override void AddMsgListeners()
        {

        }

        protected override void OnDispose()
        {
            this.monthCardTemplate = null;
            this.cfgMallType = null;
        }

        #region methonds
        public void Show(CfgMallType cfgMallType)
        {
            this.cfgMallType = cfgMallType;
            this.ViewmonthCard().Forget();
        }

        async UniTaskVoid ViewmonthCard()
        {
            this.Show();
            string assetPath = this.cfgMallType.BG;
            if (string.IsNullOrEmpty(assetPath))
                return;
            this.monthCardTemplate = await this.InitChildNodeAsync<UIN_MonthCardTemplate>(assetPath, this.ui.viewContainer);
            this.monthCardTemplate?.Show(this.cfgMallType);

        }
        #endregion methonds
    }
}